﻿using Utilities;

namespace System
{
    public static class SystemExt
    {
        public static List<FileModel> GetFileList(this string str)
        {
            if (string.IsNullOrEmpty(str))
            {
                return new List<FileModel>();
            }

            return str.Deserialize<List<FileModel>>();
        }

        public static string Right(this string str, int n)
        {
            if (str.IsEmpty() || (str.Length <= n))
            {
                return str;
            }

            return str.Substring(str.Length - n, n);
        }

    }
}


namespace System.Collections.Generic
{
    public static class IEnumerableExt
    {
        public static string GetFileString(this IEnumerable<FileModel> models)
        {
            if (models == null || !models.Any())
            {
                return string.Empty;
            }

            return models.Serialize().Replace("'", "''");
        }
    }
}